package com.cmfi.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cmfi.domain.Equipment;

// TODO 添加@Mapper
@Mapper
public interface EquipmentDao {
    @Insert("insert into tbl_equipment (equipmentName,status,uptime,shutdownTime) values(#{equipmentName},#{status},#{uptime},#{shutdownTime})")
    public int save(Equipment equipment);
    
    @Update("update tbl_equipment set status = #{status}, uptime = #{uptime}, shutdownTime = #{shutdownTime}, where id = #{id}")
    public int update(Equipment equipment);
    
    @Delete("delete from tbl_equipment where id = #{id}")
    public int delete(Long id);
    
//    @Select("select * from tbl_equipment where id = #{id}")
//    public ReadMe getById(Long id);
    
    @Select("select count(1) from tbl_equipment")
	Long count();
    
    @Select("select * from  tbl_equipment order by id DESC limit #{start},#{itemNum}")
	List<Equipment> findByPage(long start, long itemNum);
    
    @Select("select status from  tbl_equipment order by id DESC limit #{start},#{itemNum}")
	List<Equipment> findByPageAndStatus(long start, long itemNum);
    
    @Select("select * from  tbl_warnings order by id DESC limit #{start},#{itemNum}")
	List<Equipment> findByPageAndWarnings(long start, long itemNum);
    
}
